package com.tourismhengyang.impl;

import java.io.IOException;
import java.util.List;

import org.apache.ibatis.session.SqlSession;

import com.tourismhengyang.beans.Ticket;
import com.tourismhengyang.biz.ITicketBiz;
import com.tourismhengyang.dao.DBAccess;

public class TicketBizImpl implements ITicketBiz{
	private DBAccess db=new DBAccess();
	@Override
	public List<Ticket> getTicketList() {
		SqlSession session = null;
		List<Ticket> result=null;
		try {
			session=db.getSqlSession();
			ITicketBiz ticketBiz=session.getMapper(ITicketBiz.class);
			result=ticketBiz.getTicketList();
			session.commit();
		} catch (IOException e) {
			e.printStackTrace();
		}finally{
			session.close();
		}
		return result;
	}
	
	@Override
	public int addTicketInfo(Ticket ticket) {
		SqlSession session = null;
		int result=0;
		try {
			session=db.getSqlSession();
			ITicketBiz ticketBiz=session.getMapper(ITicketBiz.class);
			result=ticketBiz.addTicketInfo(ticket);
			session.commit();
		} catch (IOException e) {
			e.printStackTrace();
		}finally{
			session.close();
		}
		return result;
	}

	@Override
	public List<Ticket> getOneTicket(int lid) {
		SqlSession session = null;
		List<Ticket> result=null;
		try {
			session=db.getSqlSession();
			ITicketBiz ticketBiz=session.getMapper(ITicketBiz.class);
			result=ticketBiz.getOneTicket(lid);
			session.commit();
		} catch (IOException e) {
			e.printStackTrace();
		}finally{
			session.close();
		}
		return result;
	}

}
